package com.fx.oss.controller;


import com.fx.commonuntils.ReturnMessage;
import com.fx.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@Api(description = "上传文件接口")
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OssController {

    final private OssService ossService;

    //上传头像的方法
    @ApiOperation(value = "上传讲师图片")
    @PostMapping("/uploadOssFile")
    public ReturnMessage<Object> uploadOssFile(@ApiParam(name = "uploadFile", value = "测试文件上传", required = true)
                                               @RequestParam("uploadFile") MultipartFile multipartFile
    ) {
        //获取上传文件  MultipartFile
        //返回上传到oss的路径

        return ossService.uploadFileAvatar(multipartFile);
    }


}
